#pragma once

#ifndef KINECTSENSOR_H
#define KINECTSENSOR_H

#include <XnOpenNI.h>
#include <XnCppWrapper.h>
#include <XnCodecIDs.h>
#include <XnPropNames.h>
#include <glut.h>
#include "../defines.h"

class CKinectSensor
{
protected:
	bool m_IsOk;
	
	//Xn Variables
	XnStatus			m_Status;
	xn::Context			m_Context;
	xn::DepthGenerator	m_Depth;
	xn::ImageGenerator	m_Image;
	xn::ImageMetaData	m_ImageMD;
	xn::DepthMetaData	m_DepthMD;
	xn::ScriptNode		m_Script;

	XnRGB24Pixel *m_TexMap;
	unsigned int m_TexMapX, m_TexMapY;
	unsigned int m_ViewState;

	const XnDepthPixel *m_DepthPixel;
	const XnUInt8 *m_ImagePixel;
	
	float m_DepthHist[MAX_DEPTH];

	//Protected Methods
	bool InitKinect();
	void Release();

public:
	CKinectSensor();
	virtual ~CKinectSensor();

	bool Init();
	void Done();

	bool IsOk() const { return m_IsOk; }

	bool Update();
	void Render();

};

#endif